package com.dmcliver.timetracker.entity;

// Generated 19/02/2014 8:57:30 PM by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.NotNull;

/**
 * Person generated by hbm2java
 */
@Entity
@Table(name = "PERSON", schema = "TESTABUSER")
public class Person implements java.io.Serializable {

	private BigDecimal personid;
	private String username;
	private String firstname;
	private String lastname;
	private String userpassword;
	private Set<Timeentry> timeentries = new HashSet<Timeentry>(0);

	public Person() {
	}

	public Person(BigDecimal personid, String firstname, String lastname,
			String userpassword) {
		this.personid = personid;
		this.firstname = firstname;
		this.lastname = lastname;
		this.userpassword = userpassword;
	}

	public Person(BigDecimal personid, String firstname, String lastname,
			String userpassword, Set<Timeentry> timeentries) {
		this.personid = personid;
		this.firstname = firstname;
		this.lastname = lastname;
		this.userpassword = userpassword;
		this.timeentries = timeentries;
	}

	public Person(String userName, String firstName, String lastName, String password) {
	
		username = userName;
		firstname = firstName;
		lastname = lastName;
		userpassword = password;
	}

	@Id
	@Column(name = "PERSONID")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PERSONSEQ")
	@SequenceGenerator(name = "PERSONSEQ", initialValue = 1, allocationSize = 1)
	public BigDecimal getPersonid() {
		return this.personid;
	}

	public void setPersonid(BigDecimal personid) {
		this.personid = personid;
	}

	@Column(name = "FIRSTNAME", nullable = false)
	@NotNull
	public String getFirstname() {
		return this.firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	@Column(name = "LASTNAME", nullable = false)
	@NotNull
	public String getLastname() {
		return this.lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	@Column(name = "USERPASSWORD", nullable = false)
	@NotNull
	public String getUserpassword() {
		return this.userpassword;
	}

	public void setUserpassword(String userpassword) {
		this.userpassword = userpassword;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "person")
	public Set<Timeentry> getTimeentries() {
		return this.timeentries;
	}

	public void setTimeentries(Set<Timeentry> timeentries) {
		this.timeentries = timeentries;
	}

	@Transient
	public String fullName(){
		
		return firstname + " " + lastname;
	}

	@Column(name = "USERNAME", nullable = false, unique = true)
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
}
